= gitlab_ui_form_for @application_setting, url: ci_cd_admin_application_settings_path(anchor: 'js-runner-settings'), html: { class: 'fieldset-form' } do |f|
  = form_errors(@application_setting)

  %fieldset
    .form-group
      %h5
        = s_('Runners|Runner version management')
      %span.form-text.gl-mb-3.gl-mt-0
        - help_text = s_('Runners|Official runner version data is periodically fetched from GitLab.com to determine whether the runners need upgrades.')
        - learn_more_link = link_to _('Learn more.'), help_page_path('ci/runners/runners_scope.md', anchor: 'determine-which-runners-need-to-be-upgraded'), target: '_blank', rel: 'noopener noreferrer'
        = f.gitlab_ui_checkbox_component :update_runner_versions_enabled,
          s_('Runners|Fetch GitLab Runner release version data from GitLab.com'),
          help_text: '%{help_text} %{learn_more_link}'.html_safe % { help_text: help_text, learn_more_link: learn_more_link }
    .gl-form-group
      %h5
        = s_('Runners|Runner registration')
      %span.form-text.gl-mb-3.gl-mt-0
        = f.gitlab_ui_checkbox_component :allow_runner_registration_token, s_("AdminSettings|Allow runner registration token"), help_text: s_("AdminSettings|When disabled, runner registration tokens are disabled from runner pages, and maintainers and owners cannot use registration tokens to register runners. They can use runner authentication tokens instead as the more secure runner registration method.")

        = hidden_field_tag "application_setting[valid_runner_registrars][]", nil
        - ApplicationSetting::VALID_RUNNER_REGISTRAR_TYPES.each do |type|
          = f.gitlab_ui_checkbox_component :valid_runner_registrars, s_("Runners|Members of the %{type} can create runners") % { type: type },
            checkbox_options: { multiple: true, checked: valid_runner_registrars.include?(type) },
            checked_value: type,
            unchecked_value: nil

  %fieldset
    = _('Set to 0 to disable rate limits.')

  %fieldset
    .form-group
      = f.label :runner_jobs_request_api_limit, s_('Runners|Maximum requests per minute to the POST /jobs/request endpoint')
      = f.number_field :runner_jobs_request_api_limit, class: 'form-control gl-form-input'
      .form-text.gl-text-subtle
        = s_('Runners|Limits how many API requests a runner can make to request jobs within a 1-minute window.')

  %fieldset
    .form-group
      = f.label :runner_jobs_patch_trace_api_limit, s_('Runners|Maximum requests per minute to the PATCH /jobs/:id/trace endpoint')
      = f.number_field :runner_jobs_patch_trace_api_limit, class: 'form-control gl-form-input'
      .form-text.gl-text-subtle
        = s_('Runners|Limits how many API requests a runner can make to patch the job trace within a 1-minute window, per job token.')

  %fieldset
    .form-group
      = f.label :runner_jobs_endpoints_api_limit, s_('Runners|Maximum requests per minute to other Runner Jobs API endpoints')
      = f.number_field :runner_jobs_endpoints_api_limit, class: 'form-control gl-form-input'
      .form-text.gl-text-subtle
        = s_('Runners|Limits how many API requests a runner can make to jobs endpoints within a 1-minute window, per job token.')

  = f.submit _('Save changes'), pajamas_button: true
